﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace KPWeb.Kontrolki
{
    public partial class TimeUC : System.Web.UI.UserControl
    {
        public delegate void UserControlLoaded(object sender, EventArgs e);
        public event UserControlLoaded UserControlLoadedE;


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                for (int i = 0; i < 24; i++)
                    this.cmbHour.Items.Add(String.Format("{0:0#}", i));
                for (int i = 0; i < 60; i++)
                    this.cmbMinute.Items.Add(String.Format("{0:0#}", i));
                this.cmbHour.SelectedIndex = DateTime.Now.Hour;
                this.cmbMinute.SelectedIndex = DateTime.Now.Minute;

                if (UserControlLoadedE != null)
                    UserControlLoadedE(null, null);
            }
        }
        public int Hour
        {
            get
            {

                return this.cmbHour.SelectedIndex;

            }
            set
            {

                this.cmbHour.SelectedIndex = value;
            }
        }
        public int Minute
        {
            get
            {

                return this.cmbMinute.SelectedIndex;

            }
            set
            {

                this.cmbMinute.SelectedIndex = value;
            }
        }
        public void UstawCzas(int hour, int minute)
        {
            this.Hour = hour;
            this.Minute = minute;

        }
    }
}